home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / xcmd / dxcmds34.sit / Dartmouth XCMD's 3.4.3 / stack.txt < prev   
Text File  |  1990-04-17  |  12KB  |  384 lines

  1. -- stack: in.3
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0xD000 (can't modify, can't delete)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 7
  11. -- first background id: 2749
  12. -- card count: 48
  13. -- first card id: 9912
  14. -- list block id: 21972
  15. -- print block id: 0
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 531360 bytes
  21. -- stack block size: 10752 bytes
  22. -- created by hypercard version: 0x00000000
  23. -- compacted by hypercard version: 0x01258000
  24. -- modified by hypercard version: 0x01258000
  25. -- opened by hypercard version: 0x01258000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. on openCard
  69.   set the cursor to watch
  70.   UpdateXCMDMenu
  71.   set the cursor to hand
  72. end opencard
  73.  
  74. on openStack
  75.   if the short name of this card is "start" then DoPicture
  76.   AddMenu
  77. end openstack
  78.  
  79. on closestack
  80.   RemoveMenu
  81. end closestack
  82.  
  83. on DoPicture
  84.   -- this handler requires XCMD PictureShow and XFCN IsResource
  85.   global iSawThePicture
  86.   if (iSawThePicture is empty) and IsResource("PICT","Dartmouth Arms") then
  87.     show card field "obscure buttons"
  88.     put the visible of msg into msgVis
  89.     hide msg
  90.     lock screen
  91.     PictureShow "Dartmouth Arms",165,82,1,"onPress"
  92.     set the visible of msg to msgVis
  93.     put "Indeed" into iSawThePicture
  94.     hide card field "obscure buttons"
  95.     unlock screen with dissolve
  96.   else hide card field "obscure buttons"
  97. end DoPicture
  98.  
  99. on AddMenu
  100.   -- this handler requires XCMD MenuHandler
  101.   global XCMDsMenu
  102.   put "IndexΓǪ,SearchΓǪ,(-,InstallΓǪ,(-,(Print DocumentationΓǪ," into itemList
  103.   put "(Print SourceΓǪ,(-,(Save Source in FileΓǪ" after itemList
  104.   put itemList into XCMDsMenu
  105.   MenuHandler "Add","XCMD's",itemList
  106. end AddMenu
  107.  
  108. on RemoveMenu
  109.   -- this handler requires XCMD MenuHandler
  110.   MenuHandler "Delete","XCMD's"
  111. end RemoveMenu
  112.  
  113. on domenu anItem
  114.   global XCMDsMenu
  115.   if XCMDsMenu contains anItem then
  116.     DoXCMDs anItem -- see which item it is and do something
  117.   else   -- is an enable HyperCard item
  118.     pass domenu -- pass it on down the line
  119.     exit domenu
  120.   end if
  121. end domenu
  122.  
  123. on DoXCMDs anItem
  124.   if anItem is "IndexΓǪ" then
  125.     DoIndex
  126.   else if anItem is "SearchΓǪ" then
  127.     DoSearch
  128.   else if anItem is "InstallΓǪ" then
  129.     send "Install" to this card
  130.   else if anItem is "Print DocumentationΓǪ" then
  131.     DoPrintDoc
  132.   else if anItem is "Print SourceΓǪ" then
  133.     DoPrintSource
  134.   else if anItem is "Save Source in FileΓǪ" then
  135.     DoSourceToFile
  136.   end if
  137. end DoXCMDs
  138.  
  139. on DoIndex
  140.   -- this handler requires XFCN XScrollBox
  141.   global gLastIndexChoice
  142.   put SortField(card field "index" of card 1) into list
  143.   if gLastIndexChoice is empty then
  144.     put 1 into gLastIndexChoice
  145.   end if
  146.   get XScrollBox(gLastIndexChoice,"Choose an XCMD:",list)
  147.   go to this card -- update the window
  148.   if it is not empty then
  149.     set the cursor to watch
  150.     put item 1 of it into gLastIndexChoice
  151.     go card item 2 of it
  152.     set the cursor to hand
  153.   end if
  154.   choose browse tool
  155. end DoIndex
  156.  
  157. on DoSearch
  158.   -- this handler requires the following resources:
  159.   -- DLOG "Find",DITL "Find",XFCN "ModalDialog"
  160.   global findMode,whatToFind
  161.   put whatToFind into line 4 of dialogInput
  162.   if findMode is "whole" then
  163.     put "ON" into line 5 of dialogInput
  164.   else if findMode is "string" then
  165.     put "ON" into line 6 of dialogInput
  166.   else put "ON" into line 7 of dialogInput
  167.   put ModalDialog("find",dialogInput,cardCenter) into dialogOutput
  168.   if dialogOutput is "Cancel" then exit DoSearch
  169.   put line 4 of dialogOutput into whatToFind
  170.   if line 5 of dialogOutput is "ON" then
  171.     put "whole" into findMode
  172.   else if line 6 of dialogOutput is "ON" then
  173.     put "string" into findMode
  174.   else put empty into findMode
  175.   put "find" && findMode && quote & whatToFind & quote into command
  176.   do command
  177. end DoSearch
  178.  
  179. on DoPrintDoc
  180.   -- this handler requires XCMD PrintField and XFCN ObjectExists
  181.   if ObjectExists("card field Documentation") then
  182.     PrintField "card field Documentation",1
  183.   else if ObjectExists("field Documentation") then
  184.     PrintField "field Documentation",1,36,36,36,36
  185.   end if
  186. end DoPrintDoc
  187.  
  188. on DoPrintSource
  189.   -- this handler requires XCMD PrintField and XFCN ObjectExists
  190.   if ObjectExists("card field source") then
  191.     PrintField "card field source",1,36,36,36,36
  192.   end if
  193.   if ObjectExists("card field source1") then
  194.     PrintField "card field source1",1,36,36,36,36
  195.     if the result is "Cancel" then exit DoPrintSource
  196.   end if
  197.   if ObjectExists("card field source2") then
  198.     PrintField "card field source2",1,36,36,36,36
  199.   end if
  200. end DoPrintSource
  201.  
  202. on ShowError theError
  203.   answer "Sorry, an error occurred.  (" & theError & ")"
  204. end ShowError
  205.  
  206. on DoSourceToFile
  207.   -- this handler requires XCMD WriteToFile and XFCN ObjectExists
  208.   put the short name of this card into fileName
  209.   if the short name of this background is "Roger's" then
  210.     put ".c" after fileName
  211.     put "KAHL" into creator
  212.   else if the short name of this background is "Kevin's" then
  213.     put ".p" after fileName
  214.     put "MPS " into creator
  215.   end if
  216.   if ObjectExists("card field source") then
  217.     WriteToFile card field "Source",FALSE,fileName,FALSE,creator
  218.     put the result into theResult
  219.     if word 1 of theResult is "Error" then ShowError
  220.   end if
  221.   -- the sources to MenuHandler and ModalDialog are in two parts,
  222.   -- therefore the following:
  223.   if ObjectExists("card field source1") and ObjectExists("card field source2") then
  224.     WriteToFile card field "Source1",FALSE,fileName,FALSE,creator
  225.     put the result into theResult
  226.     if theResult is "Cancel" then exit DoSourceToFile
  227.     if word 1 of theResult is "Error" then
  228.       delete word 1 of theResult
  229.       ShowError theResult
  230.       exit DoSourceToFile
  231.     end if
  232.     WriteToFile card field "Source2",TRUE,theResult,TRUE
  233.   end if
  234. end DoSourceToFile
  235.  
  236. on UpdateXCMDMenu
  237.   -- this handler requires XCMD MenuHandler and XFCN ObjectExists
  238.   if ObjectExists("card field Documentation") or ObjectExists("field Documentation")
  239.   then
  240.   MenuHandler "Enable","XCMD's","Print DocumentationΓǪ"
  241. else
  242.   MenuHandler "Disable","XCMD's","Print DocumentationΓǪ"
  243. end if
  244. if ObjectExists("card field source") or ObjectExists("card field source1") or ObjectExists("card field source2")
  245. then
  246. MenuHandler "Enable","XCMD's","Print SourceΓǪ"
  247. MenuHandler "Enable","XCMD's","Save Source in FileΓǪ"
  248. else
  249.   MenuHandler "Disable","XCMD's","Print SourceΓǪ"
  250.   MenuHandler "Disable","XCMD's","Save Source in FileΓǪ"
  251. end if
  252. if Offset("Install",the script of this card) > 0 then MenuHandler "Enable","XCMD's","InstallΓǪ"
  253. else MenuHandler "Disable","XCMD's","InstallΓǪ"
  254. end UpdateXCMDMenu
  255.  
  256. function ResInStack resType,resName,resID,stackName
  257. global resInfo
  258. lock screen
  259. push card
  260. go to stack stackName
  261. put the long name of this stack into stackPathname
  262. delete word 1 of stackPathname
  263. delete char 1 of stackPathname
  264. delete last char of stackPathName
  265. put IsResource(resType,resName,resID,TRUE) into resExists
  266. pop card
  267. unlock screen
  268. if resExists is FALSE then return FALSE
  269. else return (item 5 of resInfo is stackPathname)
  270. end ResInStack
  271.  
  272. on InstallResource resType,resName,targetStack
  273.   global resInfo
  274.   set cursor to watch
  275.   if not IsResource(resType,resName) THEN
  276.     answer resType && quote & resName & quote && "does not exist."
  277.     exit InstallResource
  278.   end if
  279.   put item 3 of resInfo into resID
  280.   put the long name of this stack into thisStack
  281.   delete first word of thisStack
  282.   delete first char of thisStack
  283.   delete last char of thisStack
  284.   if targetStack is thisStack then exit InstallResource
  285.   set lockMessages to TRUE
  286.   lock screen
  287.   push card
  288.   go stack targetStack
  289.   if ResInStack(resType,resName,empty,targetStack) then
  290.     answer "Replace" && resType && quote & resName & quote & "?" with "OK" or "Cancel"
  291.     if it is "Cancel" then
  292.       pop card
  293.       unlock screen
  294.       set lockMessages to FALSE
  295.       exit InstallResource
  296.     end if
  297.   end if
  298.   if ResInStack(resType,empty,resID,targetStack) then
  299.     if item 2 of resInfo is not resName then
  300.       answer "Replace" && resType && resID & "?" with "OK" or "Cancel"
  301.       if it is "Cancel" then
  302.         pop card
  303.         unlock screen
  304.         set lockMessages to FALSE
  305.         exit InstallResource
  306.       end if
  307.     end if
  308.   end if
  309.   pop card
  310.   RInstall resType,resName,targetStack
  311.   get the result
  312.   if it is not empty then answer it
  313.   unlock screen
  314.   set lockMessages to FALSE
  315. end InstallResource
  316.  
  317. function ChooseTargetStack
  318. set lockMessages to TRUE
  319. lock screen
  320. push card
  321. put the short name of this card into resName
  322. if LENGTH(resName) > 14 then put "resource" into resName
  323. go stack "target stack for" && resName
  324. put the long name of this stack into targetStack
  325. delete first word of targetStack
  326. delete first char of targetStack
  327. delete last char of targetStack
  328. pop card
  329. unlock screen
  330. set lockMessages to FALSE
  331. return targetStack
  332. end ChooseTargetStack
  333.  
  334. on lockFields lockOrUnlock
  335.   set lockMessages to true
  336.   put the number of bgs into bNum
  337.   repeat with b = 1 to bNum
  338.     put "background"&&b
  339.     go bg b
  340.     put the number of fields into fNum
  341.     repeat with f = 1 to fNum
  342.       put the name of field f into fname
  343.       set the lockText of fname to lockOrUnlock
  344.     end repeat
  345.   end repeat
  346.   go first
  347.   put the number of cards into cNum
  348.   repeat with c = 1 to cNum
  349.     put "card"&&c
  350.     go card c
  351.     put the number of card fields into fNum
  352.     repeat with f = 1 to fNum
  353.       put the id of card field f into fID
  354.       set the locktext of card field ID fID to lockOrUnlock
  355.     end repeat
  356.   end repeat
  357.   go first
  358.   set lockMessages to false
  359.   hide msg
  360. end lockFields
  361.  
  362.  
  363. on SetProtect lockOrUnlock
  364.   set lockMessages to true
  365.   put the number of bgs into bNum
  366.   repeat with b = 1 to bNum
  367.     put "background"&&b
  368.     go bg b
  369.     set cantDelete of this bg to lockOrUnlock
  370.   end repeat
  371.   go first
  372.   put the number of cards into cNum
  373.   repeat with c = 1 to cNum
  374.     put "card"&&c
  375.     go card c
  376.     set cantDelete of this card to lockOrUnlock
  377.   end repeat
  378.   go first
  379.   set lockMessages to false
  380.   hide msg
  381. end SetProtect
  382.  
  383.  
  384.